<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增农业问题')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-agriQuestion-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">会员ID：</label>
            <div class="col-sm-8">
                <input name="memberId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">作物ID：</label>
            <div class="col-sm-8">
                <input name="cropId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">版块ID：</label>
            <div class="col-sm-8">
                <input name="sectionId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题：</label>
            <div class="col-sm-8">
                <textarea name="ask" class="form-control"></textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">问题描述：</label>
            <div class="col-sm-8">
                <textarea name="describe" class="form-control"></textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">图片：</label>
            <div class="col-sm-8">
                <input id="img" name="file" class="form-control" type="file" multiple/>
            </div>
            <input name="img" id="imgUrl" class="form-control" style="display: none">
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">行政区划编码：</label>
            <div class="col-sm-8">
                <input name="areaCode" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">行政区划名称：</label>
            <div class="col-sm-8">
                <input name="areaName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">阅读数：</label>
            <div class="col-sm-8">
                <input name="readCount" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('question_status')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">删除标记：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('del_flag')}">
                    <input type="radio" th:id="${'delFlag_' + dict.dictCode}" name="delFlag"
                           th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${'delFlag_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">提问的系统名称：</label>
            <div class="col-sm-8">
                <input name="sysName" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="utils/js-utils :: imageUpload"/>
<script type="text/javascript">

    var prefix = ctx + "agriculture/agriQuestion"

    $(function () {
        //注册图片上传组件
        imageUpload(9, "img", (code, data) => {
            if (code === 0) {
                $("#imgUrl").val(data);
            } else {
                alert(data);
            }
        });
    });

    $("#form-agriQuestion-add").validate({
        focusCleanup: true
    });


    function submitHandler() {
        if ($.validate.form()) {
            $("#imgUrl").show();
            var obj = $('#form-agriQuestion-add').serialize()
            $("#imgUrl").hide();
            $.operate.save(prefix + "/add", obj);
        }
    }
</script>
</body>
</html>
